(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 11.2' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       158,          7]
NotebookDataLength[     14563,        284]
NotebookOptionsPosition[     13843,        265]
NotebookOutlinePosition[     14229,        282]
CellTagsIndexPosition[     14186,        279]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[
 RowBox[{
  RowBox[{"(*", "\:76d1\:6d4b\:4e13\:680f\:7684cv\:53f7", "*)"}], 
  RowBox[{
   RowBox[{"cv", "=", "404336"}], ";", 
   RowBox[{"(*", 
    RowBox[{"\:76d1\:6d4b\:5468\:671f", 
     RowBox[{"\:ff08", "\:79d2", "\:ff09"}]}], "*)"}], 
   RowBox[{"fuse", "=", "300"}], ";", 
   RowBox[{"(*", 
    RowBox[{"\:65e0\:9650\:8fd0\:884c", "\:ff0c", 
     RowBox[{"\:4f7f\:7528Alt", "+", 
      RowBox[{".", "\:505c\:6b62"}]}]}], "*)"}]}]}]], "Input",
 CellChangeTimes->{{3.7333447812333612`*^9, 3.7333447942201037`*^9}, {
   3.733344869459407*^9, 3.7333448929627514`*^9}, {3.7333449487321453`*^9, 
   3.7333450000522175`*^9}, {3.7333450731253195`*^9, 
   3.7333450761853237`*^9}, {3.733345165536449*^9, 3.7333451842164755`*^9}, {
   3.7333452268365345`*^9, 3.733345270596596*^9}, {3.7333458356391163`*^9, 
   3.733345845119129*^9}, {3.7333458864491873`*^9, 3.733345901099208*^9}, {
   3.733345976329313*^9, 3.733346050159416*^9}, {3.733346156419565*^9, 
   3.73334622421966*^9}, {3.7333464362909565`*^9, 3.733346444741969*^9}, 
   3.7333472353470755`*^9, {3.733347992954562*^9, 3.7333479954845657`*^9}, {
   3.7333480546646485`*^9, 3.733348063264661*^9}, {3.7333481047847185`*^9, 
   3.73334810570472*^9}, {3.733350750202597*^9, 3.733350751212599*^9}, {
   3.7333508783337765`*^9, 3.7333509985839453`*^9}, 3.7333513451544304`*^9, {
   3.7333513759144735`*^9, 3.7333514004445076`*^9}, {3.7333514505845776`*^9, 
   3.733351475224612*^9}, {3.733351565514739*^9, 3.7333515667447405`*^9}, {
   3.7333533730652714`*^9, 3.7333533975953054`*^9}, 3.7333560115433426`*^9, 
   3.73404181594972*^9, 3.73404189422983*^9, {3.734042046090042*^9, 
   3.7340420469500437`*^9}, 3.734042091500106*^9, 3.734042329690439*^9, 
   3.734042391150525*^9, {3.734042602210821*^9, 3.734042635340867*^9}, {
   3.7340426948909507`*^9, 3.7340426986309557`*^9}, 3.7340428537331743`*^9, {
   3.7340434503840094`*^9, 3.734043464294029*^9}, {3.734048284159063*^9, 
   3.7340482851790643`*^9}, 3.7340493758925915`*^9, {3.7340534306432686`*^9, 
   3.73405343154327*^9}, {3.734053503693371*^9, 3.734053532863412*^9}, {
   3.734089773212278*^9, 3.7340897850422945`*^9}, {3.734090518553906*^9, 
   3.7340905546239567`*^9}, {3.7340911201947484`*^9, 
   3.7340911355647697`*^9}, {3.7340913145750203`*^9, 3.734091327535039*^9}, {
   3.7340920581220617`*^9, 
   3.7340921545021973`*^9}},ExpressionUUID->"1dc22295-016a-49f3-af38-\
c221317654d3"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"address", "=", 
   RowBox[{
    RowBox[{"NotebookDirectory", "[", "]"}], "<>", "\"\<Article\>\"", "<>", 
    RowBox[{"ToString", "[", "cv", "]"}], "<>", "\"\<.csv\>\""}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"replacelist", "=", 
   RowBox[{"{", 
    RowBox[{
    "\"\<view\>\"", ",", "\"\<like\>\"", ",", "\"\<favorite\>\"", ",", 
     "\"\<share\>\"", ",", "\"\<reply\>\"", ",", "\"\<coin\>\""}], "}"}]}], 
  ";"}]}], "Input",
 CellChangeTimes->{{3.7333447812333612`*^9, 3.7333447942201037`*^9}, {
   3.733344869459407*^9, 3.7333448929627514`*^9}, {3.7333449487321453`*^9, 
   3.7333450000522175`*^9}, {3.7333450731253195`*^9, 
   3.7333450761853237`*^9}, {3.733345165536449*^9, 3.7333451842164755`*^9}, {
   3.7333452268365345`*^9, 3.733345270596596*^9}, {3.7333458356391163`*^9, 
   3.733345845119129*^9}, {3.7333458864491873`*^9, 3.733345901099208*^9}, {
   3.733345976329313*^9, 3.733346050159416*^9}, {3.733346156419565*^9, 
   3.73334622421966*^9}, {3.7333464362909565`*^9, 3.733346444741969*^9}, 
   3.7333472353470755`*^9, {3.733347992954562*^9, 3.7333479954845657`*^9}, {
   3.7333480546646485`*^9, 3.733348063264661*^9}, {3.7333481047847185`*^9, 
   3.73334810570472*^9}, {3.733350750202597*^9, 3.733350751212599*^9}, {
   3.7333508783337765`*^9, 3.7333509985839453`*^9}, 3.7333513451544304`*^9, {
   3.7333513759144735`*^9, 3.7333514004445076`*^9}, {3.7333514505845776`*^9, 
   3.733351475224612*^9}, {3.733351565514739*^9, 3.7333515667447405`*^9}, {
   3.7333533730652714`*^9, 3.7333533975953054`*^9}, 3.7333560115433426`*^9, 
   3.73404181594972*^9, 3.73404189422983*^9, {3.734042046090042*^9, 
   3.7340420469500437`*^9}, 3.734042091500106*^9, 3.734042329690439*^9, 
   3.734042391150525*^9, {3.734042602210821*^9, 3.734042635340867*^9}, {
   3.7340426948909507`*^9, 3.7340426986309557`*^9}, 3.7340428537331743`*^9, {
   3.7340434503840094`*^9, 3.734043464294029*^9}, {3.734048284159063*^9, 
   3.7340482851790643`*^9}, 3.7340493758925915`*^9, {3.7340534306432686`*^9, 
   3.73405343154327*^9}, {3.734053503693371*^9, 3.734053532863412*^9}, {
   3.734089773212278*^9, 3.7340897850422945`*^9}, {3.734090518553906*^9, 
   3.7340905546239567`*^9}, {3.7340911201947484`*^9, 
   3.7340911385147743`*^9}, {3.7340912171248837`*^9, 
   3.7340912440149217`*^9}, {3.7340912797949715`*^9, 3.73409130717501*^9}, {
   3.734091768938657*^9, 3.7340917709586596`*^9}, 
   3.734092521370573*^9},ExpressionUUID->"86793f00-7c10-4df9-b694-\
a13e1869ee75"],

Cell[BoxData[
 RowBox[{"If", "[", 
  RowBox[{
   RowBox[{"!", 
    RowBox[{"FileExistsQ", "[", "address", "]"}]}], ",", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"OpenAppend", "[", 
     RowBox[{"address", ",", 
      RowBox[{"PageWidth", "\[Rule]", "Infinity"}]}], "]"}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{"WriteString", "[", 
     RowBox[{
      RowBox[{"Streams", "[", "address", "]"}], ",", 
      "\"\<Year,Month,Day,Hours,Minute,Second,View,Like,Favorite,Share,Reply,\
Coin\\n\>\""}], "]"}], ";", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{
      RowBox[{"Close", "[", "#", "]"}], "&"}], "/@", "stream"}], ";"}]}], 
  "]"}]], "Input",
 CellChangeTimes->{{3.7333447812333612`*^9, 3.7333447942201037`*^9}, {
   3.733344869459407*^9, 3.7333448929627514`*^9}, {3.7333449487321453`*^9, 
   3.7333450000522175`*^9}, {3.7333450731253195`*^9, 
   3.7333450761853237`*^9}, {3.733345165536449*^9, 3.7333451842164755`*^9}, {
   3.7333452268365345`*^9, 3.733345270596596*^9}, {3.7333458356391163`*^9, 
   3.733345845119129*^9}, {3.7333458864491873`*^9, 3.733345901099208*^9}, {
   3.733345976329313*^9, 3.733346050159416*^9}, {3.733346156419565*^9, 
   3.73334622421966*^9}, {3.7333464362909565`*^9, 3.733346444741969*^9}, 
   3.7333472353470755`*^9, {3.733347992954562*^9, 3.7333479954845657`*^9}, {
   3.7333480546646485`*^9, 3.733348063264661*^9}, {3.7333481047847185`*^9, 
   3.73334810570472*^9}, {3.733350750202597*^9, 3.733350751212599*^9}, {
   3.7333508783337765`*^9, 3.7333509985839453`*^9}, 3.7333513451544304`*^9, {
   3.7333513759144735`*^9, 3.7333514004445076`*^9}, {3.7333514505845776`*^9, 
   3.733351475224612*^9}, {3.733351565514739*^9, 3.7333515667447405`*^9}, {
   3.7333533730652714`*^9, 3.7333533975953054`*^9}, 3.7333560115433426`*^9, 
   3.73404181594972*^9, 3.73404189422983*^9, {3.734042046090042*^9, 
   3.7340420469500437`*^9}, 3.734042091500106*^9, 3.734042329690439*^9, 
   3.734042391150525*^9, {3.734042602210821*^9, 3.734042635340867*^9}, {
   3.7340426948909507`*^9, 3.7340426986309557`*^9}, 3.7340428537331743`*^9, {
   3.7340434503840094`*^9, 3.734043464294029*^9}, {3.734048284159063*^9, 
   3.7340482851790643`*^9}, 3.7340493758925915`*^9, {3.7340534306432686`*^9, 
   3.73405343154327*^9}, {3.734053503693371*^9, 3.734053532863412*^9}, {
   3.734089773212278*^9, 3.7340897850422945`*^9}, {3.734090518553906*^9, 
   3.7340905546239567`*^9}, {3.7340911201947484`*^9, 
   3.7340911385147743`*^9}, {3.7340912171248837`*^9, 
   3.7340912440149217`*^9}, {3.7340912797949715`*^9, 3.73409130717501*^9}, 
   3.7340913382050533`*^9, {3.7340915242453136`*^9, 3.7340915333053265`*^9}, 
   3.7340921204821496`*^9, {3.734092179932233*^9, 
   3.734092181072234*^9}},ExpressionUUID->"5e6e99e2-aba7-42e2-be7c-\
f505364870c5"],

Cell[BoxData[
 RowBox[{
  RowBox[{"getdata", "[", "cv_", "]"}], ":=", 
  RowBox[{"(", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"OpenAppend", "[", 
     RowBox[{"address", ",", 
      RowBox[{"PageWidth", "\[Rule]", "Infinity"}]}], "]"}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{"time", "=", 
     RowBox[{"StringRiffle", "[", 
      RowBox[{
       RowBox[{"ToString", "/@", 
        RowBox[{"Floor", "@", 
         RowBox[{"Now", "[", 
          RowBox[{"[", 
           RowBox[{"1", ",", 
            RowBox[{";;", "6"}]}], "]"}], "]"}]}]}], ",", "\"\<,\>\""}], 
      "]"}]}], ";", "\[IndentingNewLine]", 
    RowBox[{"data1", "=", 
     RowBox[{"Import", "[", 
      RowBox[{
       RowBox[{"\"\<https://api.bilibili.com/x/article/viewinfo?id=\>\"", "<>", 
        RowBox[{"ToString", "[", "cv", "]"}]}], ",", "\"\<JSON\>\""}], 
      "]"}]}], ";", "\[IndentingNewLine]", 
    RowBox[{"replace", "=", 
     RowBox[{"\"\<data\>\"", "/.", "data1"}]}], ";", 
    RowBox[{"rule", "=", 
     RowBox[{"\"\<stats\>\"", "/.", "replace"}]}], ";", 
    RowBox[{"stat", "=", 
     RowBox[{"ToString", "[", 
      RowBox[{"replacelist", "/.", "rule"}], "]"}]}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{"output", "=", 
     RowBox[{"time", "<>", "\"\<,\>\"", "<>", 
      RowBox[{"StringDrop", "[", 
       RowBox[{
        RowBox[{"StringDrop", "[", 
         RowBox[{"stat", ",", 
          RowBox[{"-", "1"}]}], "]"}], ",", "1"}], "]"}], "<>", 
      "\"\<\\n\>\""}]}], ";", "\[IndentingNewLine]", 
    RowBox[{"WriteString", "[", 
     RowBox[{
      RowBox[{"Streams", "[", "address", "]"}], ",", "output"}], "]"}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{
      RowBox[{"Close", "[", "#", "]"}], "&"}], "/@", "stream"}], ";"}], 
   ")"}]}]], "Input",
 CellChangeTimes->{{3.7333447812333612`*^9, 3.7333447942201037`*^9}, {
   3.733344869459407*^9, 3.7333448929627514`*^9}, {3.7333449487321453`*^9, 
   3.7333450000522175`*^9}, {3.7333450731253195`*^9, 
   3.7333450761853237`*^9}, {3.733345165536449*^9, 3.7333451842164755`*^9}, {
   3.7333452268365345`*^9, 3.733345270596596*^9}, {3.7333458356391163`*^9, 
   3.733345845119129*^9}, {3.7333458864491873`*^9, 3.733345901099208*^9}, {
   3.733345976329313*^9, 3.733346050159416*^9}, {3.733346156419565*^9, 
   3.73334622421966*^9}, {3.7333464362909565`*^9, 3.733346444741969*^9}, 
   3.7333472353470755`*^9, {3.733347992954562*^9, 3.7333479954845657`*^9}, {
   3.7333480546646485`*^9, 3.733348063264661*^9}, {3.7333481047847185`*^9, 
   3.73334810570472*^9}, {3.733350750202597*^9, 3.733350751212599*^9}, {
   3.7333508783337765`*^9, 3.7333509985839453`*^9}, 3.7333513451544304`*^9, {
   3.7333513759144735`*^9, 3.7333514004445076`*^9}, {3.7333514505845776`*^9, 
   3.733351475224612*^9}, {3.733351565514739*^9, 3.7333515667447405`*^9}, {
   3.7333533730652714`*^9, 3.7333533975953054`*^9}, 3.7333560115433426`*^9, 
   3.73404181594972*^9, 3.73404189422983*^9, {3.734042046090042*^9, 
   3.7340420469500437`*^9}, 3.734042091500106*^9, 3.734042329690439*^9, 
   3.734042391150525*^9, {3.734042602210821*^9, 3.734042635340867*^9}, {
   3.7340426948909507`*^9, 3.7340426986309557`*^9}, 3.7340428537331743`*^9, {
   3.7340434503840094`*^9, 3.7340434571240187`*^9}, 3.734043654034295*^9, {
   3.7340438286268225`*^9, 3.734043829066823*^9}, {3.734048791612773*^9, 
   3.734048827862824*^9}, {3.7340489952730584`*^9, 3.734049040703122*^9}, 
   3.7340493708025846`*^9, {3.7340494144626455`*^9, 3.734049445402689*^9}, {
   3.734049482922742*^9, 3.7340495896378913`*^9}, {3.7340496735180087`*^9, 
   3.734049675768012*^9}, 3.7340497685181417`*^9, {3.7340498445482483`*^9, 
   3.734049875878292*^9}, 3.734050417909051*^9, {3.7340895716309958`*^9, 
   3.734089649091104*^9}, {3.7340901972334557`*^9, 3.7340903043636055`*^9}, 
   3.7340903912377276`*^9, {3.7340905792339907`*^9, 3.734090586444001*^9}, {
   3.734090837824353*^9, 3.7340908433143606`*^9}, {3.7340909025144434`*^9, 
   3.734090904254446*^9}, {3.734091037424632*^9, 3.734091097584717*^9}, {
   3.7340914444452024`*^9, 3.734091582835396*^9}, {3.7340917123785777`*^9, 
   3.7340917408686175`*^9}, {3.73409217036222*^9, 
   3.734092224902296*^9}},ExpressionUUID->"574d8bbc-9a2c-4e1b-98cd-\
2515a17b62a1"],

Cell[BoxData[
 RowBox[{"While", "[", 
  RowBox[{"True", ",", 
   RowBox[{
    RowBox[{"getdata", "[", "cv", "]"}], ";", 
    RowBox[{"Pause", "[", "fuse", "]"}]}]}], "]"}]], "Input",
 CellChangeTimes->{{3.7333447812333612`*^9, 3.7333447942201037`*^9}, {
   3.733344869459407*^9, 3.7333448929627514`*^9}, {3.7333449487321453`*^9, 
   3.7333450000522175`*^9}, {3.7333450731253195`*^9, 
   3.7333450761853237`*^9}, {3.733345165536449*^9, 3.7333451842164755`*^9}, {
   3.7333452268365345`*^9, 3.733345270596596*^9}, {3.7333458356391163`*^9, 
   3.733345845119129*^9}, {3.7333458864491873`*^9, 3.733345901099208*^9}, {
   3.733345976329313*^9, 3.733346050159416*^9}, {3.733346156419565*^9, 
   3.73334622421966*^9}, {3.7333464362909565`*^9, 3.733346444741969*^9}, 
   3.7333472353470755`*^9, {3.733347992954562*^9, 3.7333479954845657`*^9}, {
   3.7333480546646485`*^9, 3.733348063264661*^9}, {3.7333481047847185`*^9, 
   3.73334810570472*^9}, {3.733350750202597*^9, 3.733350751212599*^9}, {
   3.7333508783337765`*^9, 3.7333509650738983`*^9}, {3.734042674490922*^9, 
   3.734042674950923*^9}, {3.7340428004930997`*^9, 3.7340429097132525`*^9}, {
   3.73404939586262*^9, 3.73404939639262*^9}, {3.734090572793982*^9, 
   3.7340905732139826`*^9}, {3.734091382475116*^9, 
   3.734091383365117*^9}},ExpressionUUID->"d44d6345-60fa-4486-8fd5-\
75e6885b32f7"]
},
WindowSize->{1350, 686},
WindowMargins->{{-8, Automatic}, {Automatic, 0}},
Magnification:>1.3 Inherited,
FrontEndVersion->"11.2 for Microsoft Windows (64-bit) (2017\:5e7410\:67082\
\:65e5)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[558, 20, 2415, 40, 37, "Input",ExpressionUUID->"1dc22295-016a-49f3-af38-c221317654d3"],
Cell[2976, 62, 2505, 42, 85, "Input",ExpressionUUID->"86793f00-7c10-4df9-b694-a13e1869ee75"],
Cell[5484, 106, 2770, 49, 198, "Input",ExpressionUUID->"5e6e99e2-aba7-42e2-be7c-f505364870c5"],
Cell[8257, 157, 4234, 82, 364, "Input",ExpressionUUID->"574d8bbc-9a2c-4e1b-98cd-2515a17b62a1"],
Cell[12494, 241, 1345, 22, 57, "Input",ExpressionUUID->"d44d6345-60fa-4486-8fd5-75e6885b32f7"]
}
]
*)

